function transect_magnetics(ctr,All)

%Load and plot grid data
R=region_data_all(ctr);
fname=['../../generate_profiles/data/data_',R.name,'.mat']; load(fname,'C','P');

subplot('position',[0.05 0.1 0.85 0.5]); hold on;

%identify transect numbers
tr=All.transect;
plt=find(tr(:,1)==ctr);
lines=unique(tr(plt,2));

%plot magnetic profiles
for ct=1:length(lines),
    mag=P.T(lines(ct)).mag;
    [~,m]=min(abs(P.T(ct).dist));
    mmag=mag(m);
    plot(P.T(lines(ct)).dist,mag-mmag+250*ct,'k','linewidth',1);
    plot(0,250*ct,'ro','markersize',12,'linewidth',2); 
    
    %mark BM on one side
    mag=P.T(lines(ct)).BM(1).mag;
    plot(P.T(lines(ct)).BM(1).idist,(mag-mmag)+250*ct,'r.','markersize',22);

    %mark BM on the other side
    mag=P.T(lines(ct)).BM(2).mag;
    plot(P.T(lines(ct)).BM(2).idist,(mag-mmag)+250*ct,'r.','markersize',22);
end;
axis tight; h4=axis;
for ct=1:length(lines);
    text(h4(2),250*ct,num2str(lines(ct),2),'fontsize',15,'linewidth',1);
end;

%give a little space on the left
axis([h4(1)-diff(h4(1:2))*0.05 h4(2:4)]); h4=axis;

%label
plot([0 0],h4(3:4),'k--','linewidth',1);
%text(h4(1),h4(4)-0.05*diff(h4(3:4)),R.name,'fontsize',18); 
text(h4(1),h4(4)-0.05*diff(h4(3:4)),'magnetic anomaly','fontsize',18); 
axis off;

%make a vertical bar indicating units and scaling
dx=diff(h4(1:2));
dy=diff(h4(3:4));
x=[1 1]*h4(1)+0.001*dx;
y=[h4(4)-0.15*dy h4(4)-0.15*dy-200];
plot(x,y,'k','linewidth',1.5);
if dy>8*250;
    label=[0 200];
end;
if dy<=8*250 & dy>4*250;
    label=[0 100 200];
end;
if dy<=4*250;
    label=[0 50 100 150 200];
end;

%transect number label
for ct=1:length(label);
    plot([x(1) x(1)+0.005*dx],y(2)*[1 1]+label(ct),'k','linewidth',1.5);
    text(x(1)+0.01*dx,y(2)+label(ct),[num2str(label(ct)),' nT'],'linewidth',1.5,'fontsize',12);
end;

%make x-axis
subplot('position',[0.05 0.098 0.85 0.001]); 
axis([h4(1:2) 0 1]);
font(gca,15);
h=xlabel('distance (km)'); font(h,15);



